package com.yunji.order.emuns;

import lombok.Getter;

/**
 * @author : peter-zhu
 * @date : 2025/3/7 18:23
 * @description : TODO
 **/
@Getter
public enum RefundStatusEnum {
    //PASS会有两个结果  退款中和退款失败  不做为状态 做为状态机的命令扭转
    PASS(100, "通过"),
    APPLYING(0, "申请中"),
    REJECTED(-1, "不通过"),
    REFUNDING(1, "退款中"),
    REFUNDED(2, "已退款"),
    FAILED(-2, "退款失败"),
    CANCELED(-3, "已取消");

    private final Integer code;
    private final String value;

    RefundStatusEnum(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    // 根据 code 获取枚举
    public static RefundStatusEnum fromCode(int code) {
        for (RefundStatusEnum status : values()) {
            if (status.code == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知的退款状态 code：" + code);
    }
}
